#pragma once

#define WINDOWS_LEAN_AND_MEAN
#include <Windows.h>

// Animation system being done by David John

#include <vector>
#include "../../SGD Wrappers/CSGD_TextureManager.h"
#include "tinyxml.h"
using namespace std;
class Animation
{
public:
	Animation(void);
	~Animation(void);

	//Controls
	void Play(bool bIsLooping, float nSpeed);
	void Play(bool bIsLooping);
	void Play();
	void Pause();
	void Stop();
	void Restart();

	bool IsPlaying() const { return Playing;}
	bool IsOver() const;
	void Update(float dt);
	void Render( int nX, int nY, bool bFlipped, float fScale, DWORD dwColor );


private:
	class Frame
	{
	public:
		struct point
		{
		int x;
		int y;
		};

		struct rect
		{
		int right;
		int left;
		int bottom;
		int top;
		};
		point		    Anchorpoint;
		rect			SrcRect;
		rect			CollisionRect;
		rect			DmgRect;
		double			fDuration;
		int				nDamage;

		//something about an event/trigger here
		char trigger[32];
	};

	class Animationinfo 
	{
	public:
		Animation *     CurAnimation;
		int				CurrFrame;
		float	        TimeWaited;
	};

	Animationinfo   animation;
	vector<Frame>	Frames;
	int				TextureID;
	bool			IsLooping;
	bool			Playing;
	float			PlaybackSpeed;
public:
	bool Initialize(char* szFilename, vector<Animation *> ani);
};

